package com.zzptc.zzsgz.bdsjws.fragments;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zzptc.zzsgz.bdsjws.MyApplication;
import com.zzptc.zzsgz.bdsjws.R;
import com.zzptc.zzsgz.bdsjws.activities.AddContactsActivity;
import com.zzptc.zzsgz.bdsjws.adapter.ContactAdapter;
import com.zzptc.zzsgz.bdsjws.fragments.base.BaseFragmentbase;
import com.zzptc.zzsgz.bdsjws.vo.Contact;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by zzsgz on 2017/6/7.
 */

public class SelectContactFragment extends BaseFragmentbase {
    @BindView(R.id.rv_select_contact)
    RecyclerView rvSelectContact;
    List<Contact>  contactsList=new ArrayList<Contact>();
    ContactAdapter contactAdapter;
    @Override
    public int getXML() {
        return R.layout.select_contact_fragment;
    }
    @Override
    public void initView() {
        //项  适配器  都可以共用
//        List<Contact> anyList=new ArrayList<Contact>();
//        List<Contact> allList=MyApplication.getList();
//        //要知道输入框中输入了什么内容，再去匹配
//       if( getActivity() instanceof AddContactsActivity){
//           ((AddContactsActivity) getActivity()).;
//       }
//        for(int i=0;i<allList.size();i++){
//
//        }
      //  ContactAdapter contactAdapter=new ContactAdapter();
     //   rvSelectContact.setLayoutManager(new LinearLayoutManager(getActivity()));
    }

    @Override
    public void initData() {
        rvSelectContact.setLayoutManager(new LinearLayoutManager(MyApplication.getContext()));
        contactAdapter=new ContactAdapter(contactsList);
        rvSelectContact.setAdapter(contactAdapter);

    }
    public void getSelectContactList(List<Contact>  contacts){
       contactsList.clear();
        contactsList.addAll(contacts);
        if(contactAdapter!=null) {
            contactAdapter.notifyDataSetChanged();
        }

    }

}
